<?php
  include_once("./libraries/util.inc.php");
  include_once("./libraries/authentication.inc.php");

  session_start();
  if(isset($_SESSION["loginUsername"])) {
    //we're already logged in, shouldn't be here
    header("Location: index.php");
    exit;
  }

  printHeader();
  printBody();
  echo "<h2>",appName," New User Sign Up Page</h2>"
?>

  <form method="POST" action="./signupCheck.php">

  <table>
    <tr><td>Enter your desired username:</td>
        <td><input type="text" size=10 maxlength=10 name="signupUsername"></td>
    </tr>
    <?php
      if(isset($_SESSION["signupErrors"]["username"])) {
        echo "<tr><td><font color='red'>{$_SESSION["signupErrors"]["username"]}</font></td></tr>";
      }
    ?>
    <tr><td>Enter your password:</td>
        <td><input type="password" size=10 maxlength=10 name="signupPass1"></td>
    </tr>
    <?php
      if(isset($_SESSION["signupErrors"]["pass1"])) {
        echo "<tr><td><font color='red'>{$_SESSION["signupErrors"]["pass1"]}</font></td></tr>";
      }
    ?>
    <tr><td>Re-enter your password:</td>
        <td><input type="password" size=10 maxLength=10 name="signupPass2"></td>
    </tr>
  </table>
  <p><input type="submit" value="Add me to the system!">
  </form>

  <?php
    if(isset($_SESSION["message"])) {
      echo "<br><font color='red'>{$_SESSION["message"]}</font>";
      unset($_SESSION["message"]);
    }
  ?>
  <br><a href="login.php">Login</a>

<?php
  printFooter();
?>
